package com.example.leetcode.tree;

import com.example.leetcode.tree.common.TreeNode;
import com.example.leetcode.tree.common.TreeUtils;

import java.util.List;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode() {}
 *     TreeNode(int val) { this.val = val; }
 *     TreeNode(int val, TreeNode left, TreeNode right) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
class Solution145 {
    public List<Integer> postorderTraversal(TreeNode root) {
        return TreeUtils.postorderTraversal(root);
    }
}

public class leetcode145 {
    public static void main(String[] args) {
        Solution145 solution145 = new Solution145();
        Integer[] nums = {1,null,2,3};
        Integer[] nums1 = {};
        Integer[] nums2 = {1};
        test145(solution145, nums);
        test145(solution145, nums1);
        test145(solution145, nums2);
    }

    private static void test145(Solution145 solution145, Integer[] nums) {
        TreeNode root = TreeUtils.generateLeetcodeTree(nums);
        System.out.println(solution145.postorderTraversal(root));
    }
}
